package com.zoe.onelink.core.web.jackson.sensitive.strategy;

import com.zoe.onelink.annotation.data.sensitive.enumeration.SensitiveStrategy;
import lombok.AllArgsConstructor;

import javax.annotation.PostConstruct;
import java.util.Map;

/**
 * <p>标题: 脱敏策略管理器</p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2021</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2021-11-11
 */
@AllArgsConstructor
public class SensitiveStrategyManager {

    private final Map<String, ISensitiveStrategy> strategyMap;

    private static SensitiveStrategyManager self;


    @PostConstruct
    public void init() {
        self = this;
    }

    public static ISensitiveStrategy get(String name) {
        if (self.strategyMap == null) {
            return null;
        }
        return self.strategyMap.get(ISensitiveStrategy.BEAN_NAME_PREFIX.concat(name));
    }

    public static ISensitiveStrategy get(SensitiveStrategy type) {
        if (type == null) {
            return null;
        }
        return get(type.name());
    }

    public static Map<String, ISensitiveStrategy> getMap() {
        return self.strategyMap;
    }

}
